﻿Imports System
Imports System.Collections.ObjectModel
Imports System.Xml.Serialization

''' <summary>
''' Describes the kinship between Item objects
''' </summary>
Public MustInherit Class Relationship

    Private m_relationshipType As RelationshipType

    Private m_relationTo As Item

    ' The Item's Id will be serialized instead of the relationTo Item object to avoid
    ' circular references during Xml Serialization. When family data is loaded, the corresponding
    ' Item object will be assigned to the relationTo property (please see app.xaml.cs).
    Private m_itemId As String


    ''' <summary>
    ''' The Type of relationship.  Parent, child, sibling
    ''' </summary>
    Public Property RelationshipType() As RelationshipType
        Get
            Return m_relationshipType
        End Get
        Set(ByVal value As RelationshipType)
            m_relationshipType = value
        End Set
    End Property


    ''' <summary>
    ''' The item id the relationship is to. See comment on itemId above.
    ''' </summary>
    Public Property RelationTo() As Item
        Get
            Return m_relationTo
        End Get
        Set(ByVal value As Item)
            m_relationTo = value
            m_itemId = value.Id
        End Set
    End Property

    Public Property ItemId() As String
        Get
            Return m_itemId
        End Get
        Set(ByVal value As String)
            m_itemId = value
        End Set
    End Property

    Public Sub New(ByVal Item As Item, ByVal RelationshipType As RelationshipType)
        Me.m_relationTo = Item
        Me.m_itemId = Item.Id
        Me.m_relationshipType = RelationshipType
    End Sub

End Class
